<?php include_once('./configs/config.php');?><!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title><?php if ($_COOKIE["liheid"]==$_GET[key]){
$sql="SELECT * FROM `510_lihekai` where `kid`='$_GET[key]'";
$total=mysql_num_rows(mysql_query($sql));
if ($total<$wxrs){
echo "已有".$total."位朋友帮你拆了红包！";
}else{
echo "恭喜！您已成功打开红包";
}
}else{
echo "亲，终于等到你了！";}?></title>
<meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1.0, maximum-scale=1.0" />
<script type="text/javascript" src="template/wb/js/zepto.js"></script>
<style type="text/css">
body{padding:0;margin:0;font-size:14px;font-family:Arial;}h1,h2,h3,h4,h5,h6,hr,p,blockquote,dl,dt,dd,ul,ol,li,pre,form,fieldset,legend,button,input,textarea,th,td{margin:0;padding:0;}dl,dt,dd,ul,li,ol{list-style:none;}img{border:0;}.clearfix:after{content:".";display:block;height:0;clear:both;visibility:hidden}
body{background:url(template/wb/images/tb.png) repeat-x;background-size:1px 324px;}
.main{width:100%;}
.main .box{width:100%;height:324px;background:url(template/wb/images/bg.jpg) center 0 no-repeat;background-size:320px 324px;display:block;}
.main .title{line-height:30px;font-size:18px;color:#fff;text-align:center;text-shadow:1px 1px 0 #d28ea7;padding-top:20px;}
.main .cont{width:100%;height:257px;text-align:center;overflow:hidden;}
.main .btn{width:100%;text-align:center;margin:5px auto;}
.main .btn span{display:inline-block;width:145px;height:49px;line-height:49px;background:url(template/wb/images/button_1.png) no-repeat;background-size:145px 49px;color:#fff;font-size:18px;text-align:center;margin:0 5px;}
#btn_box{background:url(template/wb/images/button_3.png) no-repeat;background-size:145px 49px;}
#grey_bg{position:fixed;top:0;left:0;width:100%;height:100%;background:rgba(51,51,51,0.8);z-index:1000;display:none;}
#grey_bg p{float:right;width:320px;text-align:center;color:#fff;font-size:20px;line-height:1.4em;background:url(template/wb/images/jt.png) 250px 10px no-repeat;background-size:40px 40px;padding-top:55px;}
.main p{text-align:center;font-size:12px;color:#333;}
.jj{text-align:center;font-size:13px;color:#999;font-weight: bold;padding-top: 3px;padding-bottom: 3px;background-color: #0F0;}
</style>

</head>

<body><link rel="stylesheet" type="text/css" href="bdad.css"><?php if ($_COOKIE["liheid"]==$_GET[key]){
if ($total<$wxrs){?>
<div class="main">
	<div class="box">
		<div class="title">再有<span><?php echo $wxrs-$total?></span>位朋友的帮助，红包就打开了。<br>
      <strong>继续找朋友帮忙吧……</strong></div>
		<div class="cont"><img src="template/wb/images/box4.png" width="210" height="210" /></div>
	</div><!--/box-->
	<div class="btn" onClick="showBg(1)"><span>继续分享</span></div>
	<p onClick="window.location='liebiao.php'">查看获奖名单&gt;</p>
	<div class="grey_bg" id="grey_bg" onClick="showBg(0)">
		<p>点击右上角【发送给朋友】<br />【分享到朋友圈】拉上小伙伴<br />帮你拆礼物吧</p>
	</div>
<p style="text-align:center;font-size:13px;color:#fff;">已有<?php echo $total;?>人帮你拆了礼盒<br>兑奖以提交信息成功为准</p>
</div>
<!--/main-->
<script type="text/javascript">
var mebtnopenurl = "<?php echo $wxwz?>back.php?key=<?php echo $_GET[key];?>";
var timeLineLink = "<?php echo $wxwz?>back.php?key=<?php echo $_GET[key];?>";
function showBg(n){
	if(n){
		$("#grey_bg").show();
	}else{
		$("#grey_bg").hide();
	}

}
</script>
<?php }else{ 
$iflingqu = mysql_query("SELECT * FROM 510_messages where c_mail='".$_GET[key]."'");
$iflingquok = mysql_fetch_row($iflingqu);
if ($iflingquok[0]!=""){
$kaijiang = mysql_query("SELECT * FROM 510_procut where id in (SELECT w_logo FROM 510_weblink where w_name='".$_GET[key]."')");
$kaijiangok = mysql_fetch_row($kaijiang);
?><style type="text/css">
.main .box{width:100%;height:100%;background:url(template/wb/images/bg.jpg) center 0 no-repeat;background-size:100% 100%;display:block;}
.main .cont{width:100%;height:100%;text-align:center;overflow:hidden;}
</style>
<div class="main">
  <div class="box">
		<div class="title">恭喜！<br />您已成功领取了礼物<br><?php
		$ifkaijiang = mysql_query("SELECT * FROM 510_weblink where w_name='".$_GET[key]."'");
$ifkaijiangok = mysql_fetch_row($ifkaijiang);
if ($ifkaijiangok[4]!=""){
$kaijiang = mysql_query("SELECT * FROM 510_procut where id=".$ifkaijiangok[4]);
$kaijiangok = mysql_fetch_row($kaijiang);
} else {
		$proresult = mysql_query("SELECT * FROM 510_procut order by model asc");
		$liheproi="";
		$jiangpin="";
		$jiangpini=0;
while($lihepro = mysql_fetch_array($proresult))
  {
  $jiangpinid=$lihepro['id'];
  $jiangpinmodel=$lihepro['model'];
  $jiangpini=$jiangpini+$jiangpinmodel;
  FOR ($i = 1; $i <= $jiangpinmodel; $i++) 
{ 
$jiangpin=$jiangpin.$jiangpinid.",";
} 
}
 $jiangpin = explode(",",substr($jiangpin,0,strlen($jiangpin)-1));
 $kaijiang = mysql_query("SELECT * FROM 510_procut where id=".$jiangpin[rand(0,$jiangpini-1)]);
$kaijiangok = mysql_fetch_row($kaijiang);
$liheover = mysql_query("UPDATE 510_weblink SET w_logo = '".$kaijiangok[0]."' WHERE w_name = '".$_GET[key]."' ");
}
echo "<img src=\"".$kaijiangok[6]."\" width=\"210\" height=\"210\" /><br><font color=#fff>".$kaijiangok[2]."</font>";
  ?></div>
		<div class="cont" style="color:#FFFFFF; width:200px; text-align:left; margin-left:auto; margin-right:auto;">兑奖方法：<br>
1、关注/打开【<?php echo $wxzbf?>】微信号<?php echo $wxwxh?><br>
2、截图发到公众号领取奖品<br>
编号：<?php echo $_COOKIE["liheid"];?><br></div>
	<div class="btn" onClick="window.location='<?php echo $wxgz?>'"><span>关注微信</span></div><br>
<br>
	</div><!--/box-->
</div>
<?php }else{?>
<div class="main">
  <div class="box">
		<div class="title">恭喜！在你<?php echo $total?>位朋友的帮助下<br />你已成功打开了红包，礼品是：</div>	
		<div class="cont"><?php
		$ifkaijiang = mysql_query("SELECT * FROM 510_weblink where w_name='".$_GET[key]."'");
$ifkaijiangok = mysql_fetch_row($ifkaijiang);
if ($ifkaijiangok[4]!=""){
$kaijiang = mysql_query("SELECT * FROM 510_procut where id=".$ifkaijiangok[4]);
$kaijiangok = mysql_fetch_row($kaijiang);
} else {
		$proresult = mysql_query("SELECT * FROM 510_procut order by model asc");
		$liheproi="";
		$jiangpin="";
		$jiangpini=0;
while($lihepro = mysql_fetch_array($proresult))
  {
  $jiangpinid=$lihepro['id'];
  $jiangpinmodel=$lihepro['model'];
  $jiangpini=$jiangpini+$jiangpinmodel;
  FOR ($i = 1; $i <= $jiangpinmodel; $i++) 
{ 
$jiangpin=$jiangpin.$jiangpinid.",";
} 
}
 $jiangpin = explode(",",substr($jiangpin,0,strlen($jiangpin)-1));
 $kaijiang = mysql_query("SELECT * FROM 510_procut where id=".$jiangpin[rand(0,$jiangpini-1)]);
$kaijiangok = mysql_fetch_row($kaijiang);
$liheover = mysql_query("UPDATE 510_weblink SET w_logo = '".$kaijiangok[0]."' WHERE w_name = '".$_GET[key]."' ");
}
echo "<img src=\"".$kaijiangok[6]."\" width=\"210\" height=\"210\" /><br><font color=#fff>".$kaijiangok[2]."</font>";
  ?></div>
	</div><!--/box-->
	<p>提交联系信息后领奖</p>
	<div class="btn" onClick="window.location='input.php?key=<?php echo $_GET[key];?>'"><span>立即领奖</span></div>
	
</div><!--/main-->
<script type="text/javascript">
var mebtnopenurl = "<?php echo $wxwz?>back.php?key=<?php echo $_GET[key];?>";
var timeLineLink = "<?php echo $wxwz?>back.php?key=<?php echo $_GET[key];?>";
function showBg(n){
	if(n){
		$("#grey_bg").show();
	}else{
		$("#grey_bg").hide();
	}

}
</script>
<?php }
}
 }else{ ?>
<div class="main">
	<div class="box">
		<div class="title" id="title">我刚领了个礼盒需要你来帮助拆开<br>
<strong>点击【帮忙拆礼盒】帮我拆一下</strong><br />
	  回头请你吃饭^_^</div>
	  <div class="cont"><img src="template/wb/images/box1.png" width="210" height="210" id="boximg" /></div>
	</div><!--/box-->
	<div class="btn"><span id="btn_box" onClick="window.location='chaikai.php?key=<?php echo $_GET[key];?>'" >帮忙拆礼盒</span><span onClick="window.location='index.php'">我也领一个</span></div>
	<div class="grey_bg" id="grey_bg" onClick="showBg(0)">
		<p>就差一点点了<br />点击右上角【发送给朋友】<br />【分享到朋友圈】<br />召唤更多小伙伴<br /></p>
	</div>
</div><!--/main-->


<script language="javascript">
var state='1';
var mebtnopenurl = "<?php echo $wxwz?>back.php?key=<?php echo $_GET[key];?>";
var timeLineLink = "<?php echo $wxwz?>back.php?key=<?php echo $_GET[key];?>";
var box_id='1';
function openBox(){
	$("#btn_box").hide();
	if(state==1){
		$("#title").html('谢谢你啦<br />你也赶快去领一个吧');
		$("#boximg").attr("src",'template/wb/images/box_open_'+box_id+'.png');
		var url='sub/share_add.php?rnd='+Math.random();
		$.post(url,{user_id:user_id,bid:bid},function(data){
                });	
	}
}
$(function(){
	addLoadEvent(preloader);//预加载
})

//预加载
function preloader(){
    if(document.images){
        var img1=new Image();
        var img2=new Image();
        var img3=new Image();
		var img4=new Image();
        var img5=new Image();
		img1.src="template/wb/images/gift1.png";
        img2.src="template/wb/images/gift2.png";
        img3.src="template/wb/images/gift3.png";
		img4.src="template/wb/images/gift4.png";
        img5.src="template/wb/images/gift5.png";
    }
}
function addLoadEvent(func){
    var oldonload=window.onload;
    if (typeof window.onload!='function'){
        window.onload=func;
    }else{
        window.onload=function(){
            if(oldonload){
                oldonload();
            }
            func();
        }
    }
}
function showBg(n){
	if(n){
		$("#grey_bg").show();
	}else{
		$("#grey_bg").hide();
	}

}
window.onload=function(){
		//showBg(1);
}
</script>
<?php }?>
<script type="text/javascript" src="template/wb/js/share_2.js"></script>


<div style="display:none;"></div>
</body>
</html>
